//
//  CreatePhoto.swift
//  
//
//  Created by Jiang Chencheng on 2024/9/11.
//

import Fluent

struct CreatePhoto: AsyncMigration {
    func prepare(on database: Database) async throws {
        try await database.schema("photo")
            .id()
            .field("room_id", .uuid, .required, .references("room", "id"))
            .field("name", .string)
            .field("url", .string, .required)
            .field("created_at", .datetime)
            .field("updated_at", .datetime)
            .field("deleted_at", .datetime)
            .create()
    }

    func revert(on database: Database) async throws {
        try await database.schema("photo").delete()
    }
}
